package com.five.monkey.feign.es.convert;

import com.five.monkey.feign.es.dao.model.Card;
import com.five.monkey.util.TimeUtils;
import com.five.monkey.vo.CardVo;
import org.springframework.beans.BeanUtils;
import java.util.Objects;

/**
 * @author 狻猊
 * @date 2022-03-29 14:44:49
 */
public class CardConvert {

    private CardConvert() {

    }

    public static CardVo esModel2vo(Card card) {
        if (Objects.isNull(card)) {
            return null;
        }
        CardVo vo = new CardVo();
        BeanUtils.copyProperties(card, vo);
        return vo;
    }

    public static Card vo2esModel(CardVo vo) {
        if (Objects.isNull(vo)) {
            return null;
        }
        Card card = new Card();
        BeanUtils.copyProperties(vo, card);
        card.setCreateTime(TimeUtils.parseDate());
        return card;
    }
}
